#include "widget.h"
#include "utils.h"

#include <QDropEvent>

Widget::Widget(QWidget *parent) : QWidget(parent)
{
    setAcceptDrops(true);
}

bool Widget::event(QEvent *event)
{
    switch (event->type())
    {
    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonRelease:
    case QEvent::MouseButtonDblClick:
    case QEvent::FocusIn:
    case QEvent::FocusOut:
    case QEvent::FocusAboutToChange:
    case QEvent::DragEnter:
    case QEvent::DragLeave:
    case QEvent::Drop:
    case QEvent::DragResponse:
        DEBUG() << "Event:" << event->type();
    default:
        break;
    }

    return QWidget::event(event);
}

void Widget::dragEnterEvent(QDragEnterEvent *event)
{
    DEBUG() << event->type();

    Widget::dragMoveEvent(event);

    QWidget::dragEnterEvent(event);
}

void Widget::dropEvent(QDropEvent *event)
{
    DEBUG() << event->type();

    QWidget::dropEvent(event);
}

void Widget::dragMoveEvent(QDragMoveEvent *event)
{
    DEBUG() << event->type();

    event->acceptProposedAction();
    update();

    QWidget::dragMoveEvent(event);
}

void Widget::mousePressEvent(QMouseEvent *event)
{
    DEBUG() << event->type();

    QWidget::mousePressEvent(event);
}
